stage.set_axis(250)
nar_color = "darkblue"
nar = codesters.Text("Let's learn about a new way to name sprites\n in your programs!", 0, 150, nar_color)
nar2 = codesters.Text(" ", 0, -125, nar_color)
var_color = "orange"
def_color = "black"
str_color = "green"
num_color = "blue"
x = -150
y = -50
spacing = 30
line1_box = codesters.Rectangle(x, y, 60, 30, "whitesmoke")
line1 = codesters.Text("sprite", x, y, var_color)
line1a = codesters.Text('= codesters.Sprite( )', x +150, y, def_color)
line1b = codesters.Text(' "pig" ', x+ 233, y, str_color)
line1_box.hide()
y -= spacing
line2_box = codesters.Rectangle(x, y, 60, 30, "whitesmoke")
line2 = codesters.Text(" ", x, y, var_color)
line2a = codesters.Text(" ", x + 100, y, def_color)
line2b = codesters.Text(" ", x + 145, y, num_color)
line2_box.hide()
line3 = codesters.Text(" ", x, y, var_color)
line3a = codesters.Text(" ", x + 150, y, def_color)
line3b = codesters.Text(' ', x + 230, y, str_color)
y-= spacing
line4 = codesters.Text(" ", x, y, var_color)
line4a = codesters.Text(" ", x+105, y, def_color)
line4b = codesters.Text(' ', x + 140, y, str_color)
explain_x = -190
explain_y = 100
conn_1 = codesters.Line(explain_x + 30, explain_y, explain_x + 35, explain_y - 145, None)
exbox1 = codesters.Rectangle(explain_x, explain_y - 10, 100, 50, None)
box1_txt = codesters.Text(" ", explain_x, explain_y - 10, nar_color)
explain_x += 120
conn_2 = codesters.Line(explain_x + 30, explain_y, explain_x + 35, explain_y - 145, None)
exbox2 = codesters.Rectangle(explain_x, explain_y - 10, 100, 50, None)
box2_txt = codesters.Text(' ', explain_x, explain_y - 10, nar_color)
explain_x += 180
conn_3 = codesters.Line(explain_x + 50, explain_y, explain_x - 20, explain_y - 145, None)
exbox3 = codesters.Rectangle(explain_x + 25, explain_y - 10, 100, 50, None)
box3_txt = codesters.Text(' ', explain_x + 25, explain_y - 10, nar_color)
explainer_sprites = [conn_1, exbox1, conn_2, exbox2, conn_3, exbox3]
explainer_txt = [box1_txt, box2_txt, box3_txt]
wilbur = codesters.Sprite("pig", 30, 10)
wilbur.set_size(.6)
stage.wait(2.5)
click_rect = codesters.Rectangle(-200, -220, 150, 60, "green", "black")
click_text = codesters.Text("Continue", -190, -220, "white")
click_text.set_size(1.2)
top_lines = [line1, line1a, line1b, line2, line2a, line2b]
bottom_lines = [line3, line3a, line3b, line4, line4a, line4b]
is_clicked = [False, False, False]
def hide_click():
click_rect.hide()
click_text.hide()
def show_click():
click_rect.show()
click_text.show()
def wrong_ans():
nar.set_text("Try clicking on the variable name!")
def go_on():
nar.set_text("Great! Now click Submit and Next to go on!")
def delete_click():
pass
def delete_all_clicks():
exbox1.event_click(delete_click)
exbox2.event_click(delete_click)
exbox3.event_click(delete_click)
def add_clicks():
exbox1.event_click(var_click)
exbox2.event_click(tool_click)
exbox3.event_click(img_click)
def var_click():
global is_clicked
is_clicked[0] = True
delete_all_clicks()
nar2.set_y(-150)
nar2.set_text("This is the variable name. \n\n We use this name to assign \n actions to sprites.")
stage.wait(1)
line2.set_text('sprite')
stage.wait(1)
line2a.set_text('.turn_right( )')
line2b.set_text('360')
wilbur.turn_right(360)
add_clicks()
if is_clicked[0] and is_clicked[1] and is_clicked[2]:
click_rect.show()
nar.hide()
click_text.set_text("Continue")
click_rect.event_click(click_2)
def tool_click():
global is_clicked
is_clicked[1] = True
delete_all_clicks()
nar2.set_text(' ')
for line in top_lines[3:]:
line.set_text(' ')
nar2.set_text("This is a Codesters tool. \n\n It creates a sprite object \n on the stage.")
stage.wait(2)
line1a.hide()
line1b.hide()
stage.wait(.5)
wilbur.hide()
stage.wait(1)
line1a.show()
line1b.show()
stage.wait(.5)
wilbur.show()
add_clicks()
if is_clicked[0] and is_clicked[1] and is_clicked[2]:
click_rect.show()
nar.hide()
click_text.set_text("Continue")
click_rect.event_click(click_2)
def img_click():
global is_clicked
is_clicked[2] = True
delete_all_clicks()
nar2.set_text(' ')
for line in top_lines[3:]:
line.set_text(' ')
nar2.set_text("This is the label we use to get a certain image\n from the Codesters image library.")
stage.wait(2)
line1b.set_text('"cow"')
stage.wait(.5)
wilbur.load_image("cow")
stage.wait(1)
line1b.set_text('"pig"')
stage.wait(0.5)
wilbur.load_image("pig")
add_clicks()
if is_clicked[0] and is_clicked[1] and is_clicked[2]:
click_rect.show()
nar.hide()
click_text.set_text("Continue")
click_rect.event_click(click_2)
def click_1():
stage.wait(.2)
nar2.set_text("This line of code creates a sprite. \nClick on each part of the diagram to learn more.")
nar.show()
conn_1.set_color("green")
exbox1.set_color('lightblue')
box1_txt.set_text("Variable\nName")
conn_2.set_color("green")
exbox2.set_color("lightblue")
box2_txt.set_text("Codesters\nTool")
conn_3.set_color("green")
exbox3.set_color("lightblue")
box3_txt.set_text("Image\nLabel")
click_rect.hide()
click_text.set_text(' ')
add_clicks()
def click_2():
hide_click()
stage.wait(.2)
for line in top_lines[3:]:
line.set_text(' ')
for s in explainer_sprites:
s.hide()
for t in explainer_txt:
t.set_text(' ')
nar2.show()
nar2.set_text('Click on the variable name to change it')
line1_box.show()
line1_box.event_click(click_3)
click_rect.event_click(wrong_ans)
def click_3():
line1_box.event_click(delete_click)
line1.set_text("wilbur")
nar.show()
nar2.hide()
nar.set_text("That's right!\n\n Now our sprite's name is wilbur!")
stage.wait(2)
line2.set_text('wilbur')
stage.wait(1)
line2a.set_text('.turn_right( )')
line2b.set_text('360')
wilbur.turn_right(360)
nar2.set_text(' ')
stage.wait(1)
tm = TestManager()
tm.display_success_message("Great job!")
# def click_4():
# nar.set_text("Oh no! Our command uses the variable name sprite, \nbut our character's name is wilbur!")
# stage.wait(.2)
# click_rect.hide()
# click_text.set_text(" ")
# nar2.set_text(" ")
# line2.set_text("sprite")
# line2a.set_text('.turn_right( )')
# line2b.set_text('360')
# click_rect.show()
# click_text.set_y(click_text.get_y() + 20)
# click_text.set_text('Click on the variable name \n in front of the command \n to change it to wilbur!')
# line2_box.show()
# line2_box.event_click(click_5)
# click_rect.event_click(wrong_ans)
# def click_5():
# nar.set_text("That's right! \n\n Our sprite, named wilbur, turns right 360 degrees! ")
# line2.set_text('wilbur')
# stage.wait(.5)
# wilbur.turn_right(360)
# nar2.set_text(" ")
# click_text.set_text("Click Submit and Next \n to move on.")
#
# click_rect.event_click(go_on)
# click_rect.hide()
click_rect.event_click(click_1)